import DDeiExperencePanels from "./panels"
import DDeiExperenceDialogs from "./dialogs";
import {DDeiPluginBase} from "ddei-editor";

class DDeiExperence extends DDeiPluginBase {
  type: string = "package"

  
  /**
   * 缺省实例
   */
  static defaultIns: DDeiExperence = new DDeiExperence(null);



  panels: object = DDeiExperencePanels;

  dialogs:object = DDeiExperenceDialogs;

  getOptions(): object {
    let options = {}
    let array = [this.panels, this.dialogs]
    array.forEach(plugin => {
      if (DDeiPluginBase.isSubclass(plugin, DDeiPluginBase)) {
        options = Object.assign({}, options, plugin.defaultIns.getOptions())
      } else if (plugin instanceof DDeiPluginBase) {
        options = Object.assign({}, options, plugin.getOptions())
      }
    });
    return options;
  }

  getPanels(editor) {
    if (DDeiPluginBase.isSubclass(this.panels, DDeiPluginBase)) {
      return this.panels.defaultIns.getPanels(editor);
    } else if (this.panels instanceof DDeiPluginBase) {
      return this.panels.getPanels(editor);
    }
  }


  getDialogs(editor){
    if (DDeiPluginBase.isSubclass(this.dialogs, DDeiPluginBase)) {
      return this.dialogs.defaultIns.getDialogs(editor);
    } else if (this.dialogs instanceof DDeiPluginBase) {
      return this.dialogs.getDialogs(editor);
    }
  }

  static configuraton(options) {
    let core = new DDeiExperence(options);
    core.panels = core.panels.configuraton(options,true)
    core.dialogs = core.dialogs.configuraton(options, true)
    return core;
  }
}

export * from "./panels"
export * from "./dialogs";
export { DDeiExperence }
export default DDeiExperence;